<template>
  <view class="notice-container">
    <e-navbar leftTitle="消息中心"></e-navbar>
    <u-gap height="15"></u-gap>
    <template v-if="noticeList.length === 0">
      <u-gap height="150"></u-gap>
      <u-empty :icon="$image('/images/msg-empty.png')" text="暂无消息"></u-empty>
    </template>
    <template v-else>
      <view class="notice-item main-card p-30 m-b-20 rela" v-for="(item, index) in noticeList" :key="index">
        <u-badge v-if="item.is_read == 0" :isDot="true" :absolute="true" :offset="[-4,-4]"></u-badge>
        <view class="hidden_two">{{item.title}}</view>
        <view class="font-26 text-999 flex col-center row-between m-t-30">
          <view>{{$u.timeFormat(item.created_at, 'yyyy.mm.dd hh:MM:ss')}}</view>
          <view class="flex col-center" @click="jumpDetail(item)">
            <text>查看详情</text>
            <view class="m-t-2">
              <u-icon name="arrow-right" size="14"></u-icon>
            </view>
          </view>
        </view>
      </view>
      <u-loadmore status="nomore" color="#999"/>
      <u-gap height="15"></u-gap>
    </template>

  </view>
</template>

<script>
let app = getApp();
export default {
  data() {
    return {
      noticeList: [],
    };
  },
  onShow() {
    this.getNoticeList();
  },
  methods: {
    async getNoticeList() {
      const res = await this.$api.notice_list();
			if(res.code == 1){
				if(res.data.list.length > 0){
          this.noticeList = res.data.list;
        }
			}
    },
    jumpDetail(item) {
			// let content = JSON.stringify(item);
      uni.navigateTo({
        // url: `/pages/mine/notice/noticeDetail/noticeDetail?content=${encodeURIComponent(content)}`
        url: `/pages/mine/notice/noticeDetail/noticeDetail?id=${item.id}`
      })
    }
  }
}
</script>

<style lang="scss" scoped>
  .notice-container{

  }
</style>
